package com.kky.pp.popup

import android.content.Context
import android.widget.ImageView
import android.widget.TextView
import com.kky.pp.R
import com.kky.pp.util.TextViewStyle
import razerdp.basepopup.BasePopupWindow

class SelectGenderPopup(var ctx: Context, var lookingFor: Int, var callback: OnCallBack) :
    BasePopupWindow(ctx) {
    init {
        setContentView(R.layout.popup_select_gender)
        initView()
    }

    var seeking = 0
    private fun initView() {
        val dialogClose = findViewById<ImageView>(R.id.imgViewPopupSelectGenderBack)
        val bntSave = findViewById<TextView>(R.id.txtPopupSelectGenderSave)
        val bntFemale = findViewById<TextView>(R.id.txtPopupSelectGenderFemale)
        val bntMale = findViewById<TextView>(R.id.txtPopupSelectGenderMale)
        val bntQueer = findViewById<TextView>(R.id.txtPopupSelectGenderQueer)
        bntSave.setOnClickListener {
            callback.callBack(seeking)
            dismiss()
        }
        dialogClose.setOnClickListener {
            dismiss()
        }
        when (lookingFor) {
            0 -> {
                bntQueer.TextViewStyle(true)
            }

            1 -> {
                bntMale.TextViewStyle(true)
            }

            2 -> {
                bntFemale.TextViewStyle(true)
            }
        }
        bntMale.setOnClickListener {
            seeking = 1
            bntMale.TextViewStyle(true)
            bntQueer.TextViewStyle(false)
            bntFemale.TextViewStyle(false)
        }
        bntFemale.setOnClickListener {
            seeking = 2
            bntMale.TextViewStyle(false)
            bntQueer.TextViewStyle(false)
            bntFemale.TextViewStyle(true)
        }
        bntQueer.setOnClickListener {
            seeking = 0
            bntMale.TextViewStyle(false)
            bntQueer.TextViewStyle(true)
            bntFemale.TextViewStyle(false)
        }
        setOutSideDismiss(true)
    }

    interface OnCallBack {
        fun callBack(seeking: Int)
    }
}